#include "main_manager.h"
#include "camera_client/acquire_network_ip.h"
#include "camera_client/client_communication.h"
#include "system_control.h"
#include "camera_device/camera_device.h"
#include "camera_image/thumbnail_process.h"
#include "camera_image/file_image.h"
#include "device_system/device_sign_file.h"
#include <QThread>

MainManager::MainManager()
{
    //依赖注入
    AcquireNetworkIP acquire_ip;
    ClientCommunication *client = new ClientCommunication(acquire_ip.networkIP(), acquire_ip.networkPort());
    SystemControl* system_control = new SystemControl(client);

    CameraDevice *camera_device = new CameraDevice;
    ThumbnailProcess *thrmbnail_process = new ThumbnailProcess;
    FileImage *file_image = new FileImage;
    DeviceSignFile *device_file = new DeviceSignFile;
    system_control->setCameraEngine(camera_device);
    system_control->setImageProcessEngine(thrmbnail_process);
    system_control->setImageSaveEngine(file_image);
    system_control->setDeviceFileEngine(device_file);
    client->setEngine(system_control);

    //线程管理调度程序执行

    thumbnail_process_thread_ = new QThread;
    thrmbnail_process->moveToThread(thumbnail_process_thread_);
    thumbnail_process_thread_->start();

    file_image_thread_ = new QThread;
    file_image->moveToThread(file_image_thread_);
    file_image_thread_->start();

    communication_thread_ = new QThread;
    client->moveToThread(communication_thread_);
    communication_thread_->start();
    //开始搜索连接服务器
    client->startScanServer();
}

MainManager::~MainManager()
{

}
